<?php

namespace App\Observers;

use App\Models\BaseModel;

class BaseModelObserver
{

    /**
     * Handle the model "created" event.
     *
     * @param  \App\Models\Model\BaseModel  $model
     * @return void
     */
    public function created($model)
    {

        if (method_exists($model, '_created'))
            $model->_created($model);
        //
    }

    /**
     * Handle the model "created" event.
     *
     * @param  \App\Models\Model\BaseModel  $model
     * @return void
     */
    public function creating($model)
    {

        if (method_exists($model, '_creating'))
            return   $model->_creating($model);
        //
    }

    public function deleting($model)
    {

        if (method_exists($model, '_deleting'))
            return  $model->_deleting($model);
    }
    /**
     * Handle the model "updated" event.
     *
     * @param  \App\Models\Model\BaseModel  $model
     * @return void
     */
    public function updated($model)
    {
        if (method_exists($model, '_updated'))
            return   $model->_updated($model);
    }

    public function updating($model)
    {
        if (method_exists($model, '_updating'))
            return   $model->_updating($model);
    }


    /**
     * Handle the model "deleted" event.
     *
     * @param  \App\Models\Model\BaseModel  $model
     * @return void
     */
    public function deleted($model)
    {
        //
        if (method_exists($model, '_deleted'))
            return  $model->_deleted($model);
    }

    /**
     * Handle the model "restored" event.
     *
     * @param  \App\Models\Model\BaseModel  $model
     * @return void
     */
    public function restored($model)
    {
        if (method_exists($model, '_restored'))
            return  $model->_restored($model);
        //
    }

    /**
     * Handle the model "force deleted" event.
     *
     * @param  \App\Models\Model\BaseModel  $model
     * @return void
     */
    public function forceDeleted($model)
    {
        if (method_exists($model, '_forceDeleted'))
            return   $model->_forceDeleted($model);
        //
    }
}
